package com.linsir.model;

import com.linsir.common.base.BaseModel;
import com.linsir.config.EovaConst;

/**
 * @author Administrator
 * @title: User
 * @projectName linsir-mu
 * @description: TODO
 * @date 2021/12/123:44
 */
public class User extends BaseModel<User> {

    public static final User dao = new User();

    public Role role;

    public int getRid(){
        return this.getInt("rid");
    }

    /**
     * 是否超级管理员
     * @return
     */
    public boolean isAdmin(){
        return getIsAdmin();
    }

    // 为兼容模版取值
    public boolean getIsAdmin(){
        if (this.getRid() == EovaConst.ADMIN_RID) {
            return true;
        }
        return false;
    }

    public void init() {
        this.role = Role.dao.findById(this.get("rid").toString());
    }

    public User getByLoginId(String loginId) {
        return this.findFirst("select * from eova_user where login_id = ?", loginId);
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }
}
